package com.hitown;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@SpringBootApplication
@ComponentScan({"com.hitown.controller","com.hitown"}) //启组件扫描
@EnableScheduling
@ServletComponentScan // 启用servlet相关组件扫描
@EnableTransactionManagement //开启事务支持
@Controller
public class SampleController extends SpringBootServletInitializer {
	
    //启动类
    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, args);
    }
    
    @GetMapping({"/","/index","login"})
	@ResponseBody
	public String index() {
		
		return "hello worldss22rr";
	}
    
    /**
     * 如此配置打包后war包才可在tomcat下使用
     * @param builder
     * @return
     */
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SampleController.class);
    }
}
